package com.bifang.module.file.gateway.controller;

import com.bifang.module.file.common.vo.fileAppClass.FileAppClassBatchVO;
import com.bifang.module.file.core.biz.FileAppClassIntegration;
import com.bifang.module.file.common.vo.fileAppClass.FileAppClassVO;
import com.bifang.module.file.common.vo.fileAppClass.FileAppClassKeyVO;
import com.bifang.module.file.common.vo.fileAppClass.FileAppClassQueryVO;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

/**
 * 文件应用分类授权管理网关
 *
 * @author shun
 * @since 2023-03-16
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "文件应用分类授权管理", description = "文件应用分类授权管理")
public class FileAppClassController {

    @Autowired
    public FileAppClassIntegration fileAppClassIntegration;

    @Operation(summary = "文件应用分类授权管理分页查询",description = "文件应用分类授权管理分页查询")
    @PostMapping(value = "/fileAppClass0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileAppClassVO>> getList(@RequestBody @Validated FileAppClassQueryVO vo) {
        return AppResponse.successData(fileAppClassIntegration.getList(vo));
    }

    @Operation(summary = "文件应用分类授权管理根据主键查询详情",description = "文件应用分类授权管理根据主键查询详情")
    @PostMapping(value = "/fileAppClass0002", produces = "application/json;charset=UTF-8")
    public AppResponse<FileAppClassVO> getById(@RequestBody @Validated FileAppClassKeyVO vo) {
        return AppResponse.successData(fileAppClassIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件应用分类授权管理新增",description = "文件应用分类授权管理新增")
    @PostMapping(value = "/fileAppClass0004", produces = "application/json;charset=UTF-8")
    public AppResponse<FileAppClassVO> add(@RequestBody @Validated(value = {Validators.Add.class}) FileAppClassVO vo) {
        return AppResponse.successData(fileAppClassIntegration.add(vo));
    }


    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件应用分类授权管理修改",description = "文件应用分类授权管理修改")
    @PostMapping(value = "/fileAppClass0005", produces = "application/json;charset=UTF-8")
    public AppResponse<FileAppClassVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) FileAppClassVO vo) {
        return AppResponse.successData(fileAppClassIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件应用分类授权管理删除",description = "文件应用分类授权管理删除")
    @PostMapping(value = "/fileAppClass0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated FileAppClassKeyVO vo) {
        fileAppClassIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }


    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件应用分类授权批量新增",description = "文件应用分类授权批量新增")
    @PostMapping(value = "/fileAppClass0007", produces = "application/json;charset=UTF-8")
    public AppResponse addBatch(@RequestBody FileAppClassBatchVO vo) {
        fileAppClassIntegration.addBatch(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件应用分类授权批量删除",description = "文件应用分类授权批量删除")
    @PostMapping(value = "/fileAppClass0008", produces = "application/json;charset=UTF-8")
    public AppResponse deleteBatch(@RequestBody FileAppClassBatchVO vo) {
        fileAppClassIntegration.deleteBatch(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件应用分类授权管理批量新增",description = "文件应用分类授权管理批量新增")
    @PostMapping(value = "/fileAppClass0009", produces = "application/json;charset=UTF-8")
    public AppResponse saveBatch(@RequestBody @Validated(value = {Validators.Add.class}) FileAppClassVO vo) {
        fileAppClassIntegration.saveBatch(vo);
        return AppResponse.success();
    }

}
